package com.admin.scroller.photoorvideo.utils;

import android.graphics.Bitmap;
import android.media.MediaMetadataRetriever;
import android.os.AsyncTask;
import android.widget.ImageView;

public class FirstBitmapTask extends AsyncTask<String,Void,Bitmap> {

    private ImageView imageView;

    public FirstBitmapTask(ImageView imageView){
        this.imageView=imageView;
    }

    @Override
    protected Bitmap doInBackground(String... strings) {
        MediaMetadataRetriever retriever=new MediaMetadataRetriever();
        retriever.setDataSource(strings[0]);
        Bitmap bitmap=retriever.getFrameAtTime(1, MediaMetadataRetriever.OPTION_CLOSEST_SYNC);
        retriever.release();
        return bitmap;
    }

    @Override
    protected void onPostExecute(Bitmap bitmap) {
        super.onPostExecute(bitmap);
        imageView.setImageBitmap(bitmap);
    }
}
